package com.itheima.homework.homework03;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo3 {
    /*
    顺序列表ArrayList中存储了如下字符串["hehe", "haha", "heihei", "gege", "gaga"]，
    请使用迭代器遍历集合，按顺序输出元素。
    */
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("hehe");
        list.add("haha");
        list.add("heihei");
        list.add("gege");
        list.add("gaga");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.println(s);
        }
    }

}
